package com.sbc.user.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sbc.user.dao.entity.TUser;
import com.sbc.user.pojo.dto.UserInfoDto;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 用户表 Mapper 接口
 * </p>
 *
 * @author songbaicheng
 * @since 2024-03-23
 */
public interface TUserMapper extends BaseMapper<TUser> {

    @Select("select tu.username,\n" +
            "       tu.real_name,\n" +
            "       tu.id_type,\n" +
            "       tu.id_card,\n" +
            "       tu.user_type,\n" +
            "       tu.verify_status,\n" +
            "       tu.post_code,\n" +
            "       tu.address,\n" +
            "       tup.telephone,\n" +
            "       tum.mail\n" +
            "from t_user tu\n" +
            "         left join t_user_phone tup on tu.username = tup.username\n" +
            "         left join t_user_mail tum on tu.username = tum.username\n" +
            "where tu.username = #{username}\n" +
            "  and tu.del_flag = '0'")
    UserInfoDto queryUserInfoByUsername(@Param("username") String username);


    @Select("select tu.username,\n" +
            "       tu.real_name,\n" +
            "       tu.id_type,\n" +
            "       tu.id_card,\n" +
            "       tu.user_type,\n" +
            "       tu.verify_status,\n" +
            "       tu.post_code,\n" +
            "       tu.address,\n" +
            "       tup.telephone,\n" +
            "       tum.mail\n" +
            "from t_user tu\n" +
            "         left join t_user_phone tup on tu.username = tup.username\n" +
            "         left join t_user_mail tum on tu.username = tum.username\n" +
            "where tu.username = #{userId}\n" +
            "  and tu.del_flag = '0'")
    UserInfoDto queryUserInfoByUserId(@Param("userId") String userId);
}
